class Parser(object):
    def __init__(self, filename):
        content = []
        with open(filename) as f:
            for line in f.readlines():
                if line.startswith('>'):
                    continue
                line = line.strip()
                content.append(line)

        self.fil = ''.join(content)
        self.pointer = 0

    def __iter__(self):
        for c in self.fil:
            yield c

    @property
    def length(self):
        return len(self.fil)

    def nextsymbol(self):
        nC = self.peek(1)
        self.pointer += 1
        return nC

    def peek(self, num = 4):
        if self.pointer + num >= len(self.fil):
            return None
        if self.pointer + num < 0:
            return None
        

        nC = self.fil[self.pointer + num]
        return nC

    def prevsymbol(self):
        nC = self.peek(-1)
        self.pointer+=-1
        return nC

    def gotoend(self):
        self.pointer=self.length-1

if __name__ == '__main__':
    p = Parser('genome1.fa')
    #for c in p:
    #    print(c)

#    print(p.nextsymbol(), p.nextsymbol(3), p.pointer, p.length)
    print p.peek(2)
